<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<html>
<head>
	<title>留学顾问管理</title>
	<link rel="stylesheet" type="text/css" href="${ctx }/styles/displaytag.css" />
	<script type="text/javascript">
		function changeAdviserLevel(id){
			var url = ctx + "/changeAdviserLevel.html?ajax=true";
			var param = "&id=" + id;
			var sf = function (msg) {
				if (msg == 1 || msg == "1" || msg == "\"1\"") {
					art.dialog.tips("<label class='success'>修改成功！</label>", 1);
					window.parent.location.reload();
					return true;
				}else if (msg == 2 || msg == "2" || msg == "\"2\"") {
					art.dialog.tips("<label class='warn'>该留学顾问还有未完成的VIP服务！</label>", 1);
					return true;
				}else{
					art.dialog.tips("<label class='error'>修改失败，请刷新页面重试！</label>", 1);
					return false;
				}
			};
			ajax(url, param, sf);
		};
		
		function changeLevel(id){
			art.dialog({
			    content: '您确定要执行该操作吗？',
			    ok: function () {
			        return changeAdviserLevel(id);
			    },
			    cancel: true,
				lock: true
			});
		}
	</script>
</head>
<body>
	<div class="container_16">
		<div class="grid_16">
			<div class="content_top">
				<span>留学顾问管理</span>
			</div>
			<div class="content_bottom">
				<div style="padding: 30px;">
					<form action="${ctx }/showOrdinaryAdviser.html" method="post">
						<table cellpadding="0" cellspacing="0" style="width: 100%;">
							<tr>
								<td style="vertical-align: middle;">
									<label>姓名：</label>
								</td>
								<td>
									<input type="text" id="nickname" name="nickname" class="input" />
								</td>
								<td style="vertical-align: middle; width: 5%;">
									<label>专业：</label>
								</td>
								<td style="width: 55%;">
									<input type="text" id="major" name="major" class="input" />
								</td>
								<td>
									<label class="btn"> <input type="submit" value="查询"> </label>
								</td>
							</tr>
						</table>
					</form>
					<display:table id="user" name="pageBean" pagesize="10" class="display_table" requestURI="">
						<display:column title="序号" value="${(pageBean.pageNumber - 1) * pageBean.objectsPerPage + user_rowNum }" style="width: 5%" />
						<display:column title="姓名" property="nickname" style="width: 15%" />
						<display:column title="专业" property="majorName" style="width: 30%" />
						<display:column title="角色" style="width: 15%">
							<fmt:message key="role.type.${user.role }"></fmt:message>							
						</display:column>
						<display:column title="注册时间" property="registtime" format="{0,date,yyyy-MM-dd}" style="width: 15%" />
						<display:column title="操作" style="width: 15%">
							<c:choose>
								<c:when test="${user.role eq 64}">
								<a href="javascript:void(0)" onclick="changeLevel(${user.id })">取消留学顾问权限</a>
								</c:when>
								<c:otherwise>
								<a href="javascript:void(0)" onclick="changeLevel(${user.id })">升级为留学顾问</a>
								</c:otherwise>
							</c:choose>
						</display:column>
					</display:table>
				</div>
			</div>
		</div>
	</div>
</body>
</html>